package com.jsh.erp.controller;

import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.service.printHistory.PrintHistoryService;
import com.jsh.erp.service.redis.RedisService;
import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.ErpInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.util.HashMap;
import java.util.Map;

import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;

/**
 * @author wy
 * @title: PrintHistoryController
 * @projectName JSH_ERP
 * @description:
 * @date 2023-04-12 14:32
 */
@RestController
@RequestMapping(value = "/printHistory")
@Api(tags = {"打印历史管理"})
public class PrintHistoryController {

    @Resource
    private PrintHistoryService printHistoryService;
    @Resource
    private RedisService redisService;

    @PostMapping(value = "/AddPrintHistory")
    @ApiOperation(value = "新增打印历史记录")
    public String AddPrintHistory(@RequestBody JSONObject obj,
                                            HttpServletRequest request, HttpServletResponse response) throws Exception {
        Map<String, Object> objectMap = new HashMap<String, Object>();
        String lanCode = redisService.getLanCodeFromSession(request);
        printHistoryService.AddPrintHistory(obj, request,lanCode);
        return returnJson(objectMap, "zh".equals(lanCode) ? ErpInfo.OK.name : ErpInfo.OK.lanCodeName, ErpInfo.OK.code);
    }
}
